package concurrencyCookBook.product;

public class P {
	private Object obj;
	private Value v;
	private Integer i=0;

	public P(Object obj,Value v) {
		this.obj=obj;
		this.v=v;
	}

	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}
	
	public Value getV() {
		return v;
	}

	public void setV(Value v) {
		this.v = v;
	}
	
	public void setValue() throws InterruptedException{
		synchronized (obj) {
			if(!"".equals(v.getV())){
				obj.wait();
			}
			i++;
			System.out.println("setValue"+i);
			obj.notifyAll();
			v.setV(i.toString());
		}
	}
}
